import React,{useState} from 'react'
import store from '../store'
import {addActionCreator,subActionCreator} from '../store/actions/counterAction'
export default function Left() {
  console.log('state',store.getState());


  const [,setVal]=useState({})
  store.subscribe(()=>{
    setVal({})  
  })
 
  
  return (
    <div style={{flex:1,height:'100vh',background:'springgreen'}}>
        <div>
          store:{store.getState().count}
        </div>
        <div>
          <button onClick={()=>{
            //store.dispatch({type:'increment'})
            store.dispatch(addActionCreator(1))
          }}>+</button>
          <button onClick={()=>{
            //store.dispatch({type:'sub'})
            store.dispatch(subActionCreator(1))
          }}>-</button>
          <button onClick={()=>{
             store.dispatch(addActionCreator(2))
          }}>+2</button>
          <button onClick={()=>{
              store.dispatch(addActionCreator(5))
          }}>+5</button>
          <button onClick={()=>{
             store.dispatch(subActionCreator(7))
          }}>-7</button>
        </div>
    </div>
  )
}
